package com.example.security.component;

import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @application:
 * @author: LiYuhang
 * @Date: 2021/3/21 18:21
 * @version: 0.1
 * @Description :
 * @Modified By:
 */
@Component
@Slf4j
public class UrlAccessDeniedHandler implements AccessDeniedHandler {
    @Override
    public void handle(HttpServletRequest httpServletRequest,HttpServletResponse httpServletResponse,
                       AccessDeniedException e) throws IOException, ServletException {
        log.error("未授权，请联系管理员 ！！ {}",e.getMessage());
    }
}
